#include<iostream>
#include<cstdio>
using namespace std;
long long n,L,R,RmL,a;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>L>>R;
	RmL=R-L+1;
	if(RmL>=n){
		cout<<n-1<<endl;
		return 0;
	}
	a = (L/n)*n;
	if((a+n-1)<=R){
		cout<<n-1<<endl;
		return 0;
	}
	cout<<(R%n)<<endl;
	fclose(stdin);
	fclose(stdout);
	return 0;
}
